package com.yztstudy.Controller;

import com.yztstudy.Service.AdminUserService;
import com.yztstudy.entity.User;
import com.yztstudy.param.CartListParam;
import com.yztstudy.param.PageParam;
import com.yztstudy.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户管理模块的表示层
 */

@RestController
public class UserController {

    @Autowired
    private AdminUserService adminUserService;


    /**
     * TODO 分页查询用户
     * @param pageParam 分页参数
     * @return
     */
    @GetMapping("/user/list")
    public R userList(PageParam pageParam)
    {
        return adminUserService.userList(pageParam);
    }


    /**
     * TODO 删除用户
     * @param cartListParam 用户主键
     * @return
     */
    @PostMapping("/user/remove")
    public R userRemove(CartListParam cartListParam)
    {
        return adminUserService.remove(cartListParam);
    }


    /**
     * TODO 更新用户
     * @param user 用户信息
     * @return
     */
    @PostMapping("/user/update")
    public R userUpdate(User user)
    {
        return adminUserService.update(user);
    }


    /**
     * TODO 添加用户
     * @param user 用户
     * @return
     */
    @PostMapping("/user/save")
    public R userSave(User user)
    {
        return adminUserService.save(user);
    }
}
